<?php

/**
 * NOTICE OF LICENSE
 *
 * THIS SOURCE FILE IS PART OF EVEBIT'S PRIVATE PROJECT.
 * 
 * DO NOT USE THIS FILE IN OTHER PLACE.
 *
 * @package   App_Sample
 * @author    Cheng Wei <berlios.o@gmail.com>
 * @version   $$Id: GetSortClass.php 130 2011-03-18 03:10:02Z cheng.wei $$
 * @copyright Copyright (c) 2008 Evebit Inc. China (http://www.evebit.com)
 */

/**
 * Get Revage rate and get rate count
 * 
 * @package   App_Sample
 * @author    Chang ZhenHua <chang.zhenhua@gmail.com>
 * @version   $$Id: GetSortClass.php 130 2011-03-18 03:10:02Z cheng.wei $$
 */
class Evebit_View_Helper_GetCommentRate extends Zend_View_Helper_Abstract {
		
	/**
	 * Get class
	 * @param string $type
	 * @param int $id
	 * @param int $infoId
	 * @return int
	 */
	function getCommentRate($type,$id){
		if(Zend_Registry::isRegistered("comment-rate"))
		$rates=Zend_Registry::get("comment-rate");
		else{
		$comment = new Default_Model_Entity_Comment();
		$rates=$comment->getRate($type);
		Zend_Registry::set("comment-rate", $rates);
		}
		foreach ($rates as $rate) {
			if($rate->getId()==$id){
				return floor($rate->getData("rate"));
			}
		}
		return -1;
	}	
	
}
